import logging
import time

import yaml
from pytest_yaml.templates import Template

logger = logging.getLogger(__name__)


def value_displace_var(res, dict_data):
    yaml_str = yaml.safe_dump(res)
    print(yaml_str, "字符串")
    new_yaml_str = Template(yaml_str).render(dict_data)
    res = yaml.safe_load(new_yaml_str)
    print(res, "替换完")
    return res


def assert_equals(assert_msg, expect_value, run_value):
    print(type(expect_value), type(run_value))
    logger.info(f" 预期结果：{expect_value}，实际运行结果{run_value},{assert_msg}")

    assert run_value == expect_value, "相等断言，断言失败"


def assert_no_equals(assert_msg, expect_value, run_value):
    print(type(expect_value), type(run_value))
    logger.info(f" 预期结果：{expect_value}，实际运行结果{run_value},{assert_msg}")

    assert run_value != expect_value, "不相等断言，断言失败"


def assert_contain(assert_msg, expect_value, run_value):
    print(type(expect_value), type(run_value))
    logger.info(f" 预期结果：{expect_value}，实际运行结果{run_value},{assert_msg}")

    assert run_value in expect_value, "包含断言，断言失败"


def assert_no_contain(assert_msg, expect_value, run_value):
    print(type(expect_value), type(run_value))
    logger.info(f" 预期结果：{expect_value}，实际运行结果{run_value},{assert_msg}")

    assert run_value not in expect_value, "不包含断言，断言失败"
